<?php
/**
 * ==============================================
 * Copy right 2015-2016 http://wei.meididi88.com
 * ----------------------------------------------
 * This is not a free software, without any authorization is not allowed to use and spread.
 * ==============================================
 * @author: hy
 * @date: 2015-9-10
 * @version: v1.0.0
 */
namespace Common\Model;

use Think\Model;

/**
 * 优惠券 Model模型类
 */
class CouponCodeModel extends Model{
	
	/**
	 * 清除优惠券缓存
	 * 
	 * @param number $id
	 */
	public function clearCache($id) {
		$cacheKey = 'Coupon_'.$id;
		
		S($cacheKey, null);
	}
	
	/**
	 * 获取优惠券信息
	 * 
	 * @param number $id		优惠券编号
	 * @return array|boolean
	 */
	public function getCouponInfo($id) {
		$cacheKey = 'Coupon_'.$id;
		
		$couponInfo = S($cacheKey);
		if (!$couponInfo) {
			$couponInfo = $this->where(array('c_id' => $id))->find();
			
			if ($couponInfo) {
				S($cacheKey, $couponInfo);
			}
		}
		
		return $couponInfo;
	}
}